package com.uroad.jilinpda.common;

import android.annotation.SuppressLint;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.telephony.TelephonyManager;

import com.uroad.lib.activity.BaseUroadActivity;


/**
 * @创建者 wlw
 * @创建时间 2018/10/25 13:50
 * @描述
 */
public class BaseActivity extends BaseUroadActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //强制竖屏
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    @SuppressLint("MissingPermission")
    protected String getDeviceId(){
        if(GlobalData.deviceId == null){
            GlobalData.deviceId = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
                    .getDeviceId();
        }
        return GlobalData.deviceId;
    }

    protected String getDeviceParam(){
        if(GlobalData.deviceParams == null){
            Build bd = new Build();
            String model = bd.MODEL;//设备类型
            String version = Build.VERSION.RELEASE;
            GlobalData.deviceParams = model + "|" + version;
        }
        return GlobalData.deviceParams;
    }

    public void doNetWork(String type){}

    /*protected void doWithoutLogin(){
        openActivity(ETCLoginActivity.class);
        finish();
    }*/

    public String getVersion() {
        try {
            PackageManager manager = this.getPackageManager();
            PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
            String version = info.versionName;
            return version;
        } catch (Exception e) {
            e.printStackTrace();
            showShortToast("获取版本号异常");
            return null;
        }
    }

    public CurrApplication getCurrApplication() {
        return (CurrApplication) getApplication();
    }
}
